package com.example.myspringtest.handler;

import com.example.myspringtest.utils.ContextUtils;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * 通过活动配置初始化bean 并注册到容器中
 */
public class InitActProxyHandler implements ApplicationListener<ContextRefreshedEvent> {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {

        System.out.println("===========================");
        // 重启服务先加载一遍 加载不发布容器刷新事件处理进入死循环
        ReloadActHandler reloadActHandler = ContextUtils.getApplicationContext().getBean(ReloadActHandler.class);
        reloadActHandler.load(false);

    }

}
